package files.controller;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import common.model.result.Result;
import files.service.IFilesService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;

@RestController
@RequestMapping("/files")
public class FilesController {
    
    @Autowired
    private IFilesService filesService;
    
    //上传图片
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result uploadImage(@RequestParam("file") MultipartFile file) {
        return filesService.uploadFile(file);
    }

    //上传图片
    @PostMapping(value = "/jiang/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result uploadShopLogo(@RequestParam("file") MultipartFile file) {
        return filesService.uploadFile(file);
    }
    
    //上传Base64格式图片
    @PostMapping("/uploadBase64")
    public Result uploadBase64Image(@RequestBody String base64Data) {
        return filesService.saveBase64Image(base64Data);
    }
} 